<%@ page session="false" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad" prefix="tr"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad/html" prefix="trh"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>

<h:panelGroup>
	<fieldset>
		<legend>Historia zmian</legend>
		<table cellpadding="3" cellspacing="0" width="100%" border="0">
			<tr>
				<td><tr:selectOneChoice
						value="#{salesmanController.auditCriteria.salesman}"
						label="Sprzedawca" required="true"
						shortDesc="Wybierz osobę odpowiedzialną za to zamówienie">
						<f:selectItems value="#{salesmanController.salesmanItems}" />
					</tr:selectOneChoice> <h:message for="salesman" styleClass="validation_info" /></td>
				<td>Data początku:</td>
				<td><t:inputDate id="dateFrom" type="date" required="false"
						styleClass="input_text"
						value="#{salesmanController.auditCriteria.dateFrom}"
						popupCalendar="true" ampm="false" /> <h:message for="dateFrom"
						styleClass="validation_info" /></td>
				<td>Data końca:</td>
				<td><t:inputDate id="dateTo" type="date" required="false"
						styleClass="input_text"
						value="#{salesmanController.auditCriteria.dateTo}"
						popupCalendar="true" ampm="false" /> 
						<h:message for="dateTo" styleClass="validation_info" /></td>
				<td><tr:inputText id="searchKey" maximumLength="45"
								required="true" label="Zamówienie" shortDesc="Kluczem może być np. numer wniosku"
								value="#{salesmanController.auditCriteria.searchKey}"/> 
				</td>
				<td><tr:commandButton text="Szukaj" actionListener="#{salesmanController.searchForAuditLog}"/></td>
			</tr>
		</table>

		<tr:table id="activityListDataTable" horizontalGridVisible="true"
			verticalGridVisible="true" inlineStyle="margin:3px"
			rendered="#{not empty salesmanController.auditList}" width="100%"
			emptyText="Lista jest pusta" rowBandingInterval="1"
			value="#{salesmanController.auditList}" var="activity" rows="50">

			<tr:column sortable="true" sortProperty="objectKey">
				<f:facet name="header">
					<h:outputText value="Zamówienie" />
				</f:facet>
				<h:outputText value="#{activity.objectKey}" />
			</tr:column>
			<tr:column sortable="true" sortProperty="action">
				<f:facet name="header">
					<h:outputText value="Akcja" />
				</f:facet>
				<h:outputText value="#{activity.action}" />
			</tr:column>
			<tr:column sortable="true" sortProperty="entityName">
				<f:facet name="header">
					<h:outputText value="Obiekt" />
				</f:facet>
				<h:outputText value="#{activity.entityName}" />
			</tr:column>
			<tr:column sortable="true" sortProperty="createdDate">
				<f:facet name="header">
					<h:outputText value="Czas" />
				</f:facet>
				<h:outputText value="#{activity.createdDate}" >
					<f:convertDateTime pattern="dd-MMMMM-yyyy HH:mm" locale="pl"/>
				</h:outputText>
			</tr:column>
			<tr:column>
				<f:facet name="header">
					<h:outputText value="Id" />
				</f:facet>
				<h:outputText value="#{activity.entityId}" />
			</tr:column>
			<f:facet name="detailStamp">
				<tr:outputFormatted value="#{activity.detail}" >
					<f:converter converterId="FormatedTextConverter" />
				</tr:outputFormatted>
			</f:facet>
		</tr:table>
	</fieldset>

</h:panelGroup>